package com.dodoke.ojserver.service.impl;

import com.dodoke.ojserver.bean.Problem;
import com.dodoke.ojserver.bean.Users;
import com.dodoke.ojserver.bean.UserList;
import com.dodoke.ojserver.bean.dto.UsersDTO;
import com.dodoke.ojserver.bean.mapper.ProblemMapStruct;
import com.dodoke.ojserver.bean.mapper.UserMapStruct;
import com.dodoke.ojserver.mapper.UserListMapper;
import com.dodoke.ojserver.service.IUserListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class UserListServiceImpl implements IUserListService {

    @Autowired
    private UserListMapper userListMapper;

//    @Override
//    public List<UserList> listUser(UserList userList) {
//        return userListMapper.listUser(userList);
//    }


    @Override
    public List<Users> selectAll() {
        System.out.println("执行查询用户列表数据service实现类");
        return userListMapper.selectAll();
    }

    @Override
    public List<Users> selectUserId(int id) {
        System.out.println("执行查询用户单条数据service实现类");
        return userListMapper.selectUserId(id);
    }

    @Override
    public void deleteUserId(int id) {
        System.out.println("执行删除用户单条数据service实现类");
        userListMapper.deleteUserId(id);
    }

    @Override
        public String deleteUserIdList(String[] ids) {
            return userListMapper.deleteUserIdList(ids);
        }

    @Override
    public int addUser(UsersDTO usersDTO) {
        System.out.println("执行添加用户数据service实现类");
        Users users = UserMapStruct.USER_MAPPER.usersDTOToUsers(usersDTO);
        String current = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format( new Date());
        Timestamp time = Timestamp.valueOf(current);
        users.setRegTime(time);
        return userListMapper.addUser(users);
    }


}
